<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcss.com/vue/2.5.16/vue.js"></script>
</head>
<body>
<div id="hd">
    <input type="text" v-star="'green'">
</div>
<script>
    var app=new Vue({
        el:'#hd',
        data:{

        },
        directives:{
            star(el,bind){
                var color=bind.value?bind.value:'red'
                el.style.cssText='color:'+color;
            },
            focus:{
                inserted(el,bind){
                    el.style.cssText='color:green'
                }
            }
        }
    })
</script>
</body>
</html>